// Realistic Unit Modification Assets Dialog 
// v. Beta

// IDD and IDC ------------------------

RUM_THel_IDD = 1050;
RUM_BttnExit_IDC = 1051;
RUM_BttnTHel_IDC = 1052;
RUM_ListTHel_IDC = 1053;
RUM_BttnStrikeTHel_IDC = 1054;
RUM_BttnStrikeSpecTHel_IDC = 1055;

// Code -------------------------------

// Buttons ----------------------------

RUM_BttnTHel = {
	_id = lbCurSel RUM_BttnStrikeSpecTHel_IDC;
	RUM_THel_Special = lbText [RUM_BttnStrikeSpecTHel_IDC,_id];
	if(RUM_THel_NonSpawn) then {
		_id = lbCurSel RUM_BttnStrikeTHel_IDC;
		_text = lbText [RUM_BttnStrikeTHel_IDC,_id];
		switch (_text) do {
			case "Insert":{
				_arry = [];
				_sel = lbCurSel RUM_ListTHel_IDC;
				_arry = RUM_THelAircraft select _sel;
				_arry execVM (RUM_PATH+"Transport\callTrans_insert.sqf");
				
				// this will delete the vehicle from the RUM PDA when selected for use.
				RUM_THelAircraft set [_sel,"del"];
				RUM_THelAircraft = RUM_THelAircraft - ["del"];
			};
			case "Shuffle":{
				_arry = [];
				_sel = lbCurSel RUM_ListTHel_IDC;
				_arry = RUM_THelAircraft select _sel;
				_arry execVM (RUM_PATH+"Transport\callTrans.sqf");
				// this will delete the vehicle from the RUM PDA when selected for use.
				RUM_THelAircraft set [_sel,"del"];
				RUM_THelAircraft = RUM_THelAircraft - ["del"];
			};
			case "Extract":{
				_arry = [];
				_sel = lbCurSel RUM_ListTHel_IDC;
				_arry = RUM_THelAircraft select _sel;
				_arry execVM (RUM_PATH+"Transport\callTrans_extract.sqf");	
				// this will delete the vehicle from the RUM PDA when selected for use.
				RUM_THelAircraft set [_sel,"del"];
				RUM_THelAircraft = RUM_THelAircraft - ["del"];
			};
			default{
				hint "shit";
			};
		};
	} else {
		_arry = [];
		_sel = lbCurSel RUM_ListTHel_IDC;
		_arry = RUM_THelAircraft_Spawn select _sel;
		_arry execVM (RUM_PATH+"Transport\callTrans_spwn.sqf");
	};
	if(true)exitwith{closeDialog 0};
};

// Lists ------------------------------

RUM_FillListTHel = {
	lbClear RUM_ListTHel_IDC;
	_list1 = [];
	_airlist = [];
	if(RUM_THel_NonSpawn)then{_airlist = RUM_THelAircraft}else{_airlist = RUM_THelAircraft_Spawn};
	for [{_n = 1},{_n <= (count _airlist)},{_n = _n+1}] do {
		_air = _airlist select (_n-1);
		_text = _air select 1;
		_list1 = _list1 + [_text];
   	};
	{lbAdd [RUM_ListTHel_IDC,_x]} foreach _list1;
	lbSetCurSel [RUM_ListTHel_IDC,0];
	if(true)exitWith{};
};

RUM_THelType = {
	if(RUM_THEL_NonSpawn) then {
		_tst=0;
		_types=["Insert","Shuffle","Extract"];
		{lbAdd [RUM_BttnStrikeTHel_IDC,_x]} foreach _types;
		lbSetCurSel [RUM_BttnStrikeTHel_IDC,0];
		while {dialog} do {
			_sel = lbCurSel RUM_ListTHel_IDC;
			if!(_sel == -1)then{
				if!(_sel == _tst)then{
					_arry = RUM_THelAircraft select _sel;
					_helo = _arry select 0;
					if (_helo isKindOf "Helicopter" or _helo isKindOf "MV22") then {
						_types = ["Insert","Shuffle","Extract"];
					} else {
						_types = ["Insert"];
					};
					lbClear RUM_BttnStrikeTHel_IDC;
					{lbAdd [RUM_BttnStrikeTHel_IDC,_x]} foreach _types;
					lbSetCurSel [RUM_BttnStrikeTHel_IDC,0];
				};
			};
		_tst = _sel;
		};
	}else{
		lbClear RUM_BttnStrikeTHel_IDC;
		lbAdd [RUM_BttnStrikeTHel_IDC,"Shuffle"];
		lbSetCurSel [RUM_BttnStrikeTHel_IDC,0];
	};
	if(true)exitWith{};
};

RUM_THelSpecList = {
	private ["_array","_tst","_types"];
	_tst = 0;
	_types = ["Normal"];
	{lbAdd [RUM_BttnStrikeSpecTHel_IDC,_x]} foreach _types;
	lbSetCurSel [RUM_BttnStrikeSpecTHel_IDC, 0];
	while {dialog} do {
		_sel = lbCurSel RUM_ListTHel_IDC;
		if!(_sel == -1)then{
			if!(_sel == _tst)then{
				_types = ["Normal"];
				if(RUM_THEL_NonSpawn)then{_array = RUM_THelAircraft select _sel}else{_array = RUM_THelAircraft_Spawn select _sel};
				lbClear RUM_BttnStrikeSpecTHel_IDC;
				_helo = _array select 0;
				if (("combat" in _array and _helo isKindOf "Helicopter") OR ("combat" in _array and !(RUM_THEL_NonSpawn))) then {_types = _types + ["Combat Landing"]};
				if (("fastrope" in _array and _helo isKindOf "Helicopter") OR ("fastrope" in _array and !(RUM_THEL_NonSpawn))) then {_types = _types + ["Fast Rope"]};
				if ("para" in _array) then {_types = _types + ["Para Drop"]};
				if (("halo" in _array and _helo isKindOf "Plane") OR ("halo" in _array and !(RUM_THEL_NonSpawn))) then {_types = _types + ["HALO Jump"]};
				{lbAdd [RUM_BttnStrikeSpecTHel_IDC,_x]} foreach _types;
				lbSetCurSel [RUM_BttnStrikeSpecTHel_IDC, 0];
			};
		};
		_tst = _sel;
	};
	if(true)exitWith{};
};


// Init -------------------------------
createDialog "RUM_THel";
call RUM_FillListTHel;
[] spawn RUM_THelType;
[] spawn RUM_THelSpecList;

if(true)exitwith{};